<!DOCTYPE html>
<html lang="cn">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./node_modules/vue/dist/vue.js"></script>
</head>
<body>
    <div id="app">
        
        您的名字:{{name}}
        <hello @rn="reName"></hello>
    </div>
    <script>

        const hello = {
            template:"<div>\
                \<button @click=rn>按一下</button>\
                </div>",
                methods: {
                    rn(){
                        this.$emit('rn',"蟀哥");
                    }
                }
           
        }

        //1.创建Vue实例
        const vm = new Vue({
            el:"#app",
            data:{
                name:"Christopher"
            },
            methods:{
                reName(data){
                    this.name = data
                }    
            },
            components: {
                hello
            }
        })

    </script>
</body>
</html>